/**
 * 
 */
package com.config;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

import org.apache.log4j.Logger;





/**
 * 容器启动时首先加载配置文�?
 * 
 * @author chengping 2013-7-25
 * 
 * @version v1.0.0
 * 
 */
public class ConfigurationInitListener implements ServletContextListener {
	private static final 	Logger LOG = Logger.getLogger(ConfigurationInitListener.class);

	/*
	 * (non-Javadoc)
	 * 
	 * @see javax.servlet.ServletContextListener#contextDestroyed(javax.servlet.ServletContextEvent)
	 */
	public void contextDestroyed(ServletContextEvent arg0) {
		Configuration.clear();
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see javax.servlet.ServletContextListener#contextInitialized(javax.servlet.ServletContextEvent)
	 */
	public void contextInitialized(ServletContextEvent arg0) {
		try {
			Configuration.init();
			ClientConfiguration.init();
			LOG.info("Init the conf success");
		} catch (ConfInitFailedException e) {
			LOG.error("Init the conf get a Exception ", e);
			throw new RuntimeException("Init the conf get a Exception");
		}
	}

}
